﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace DLL.NET50.DB.MS.CopyDrugs.Context.Migrations
{
    public partial class changekey : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_adi_flushParams_adi_dic_drug_Drug_UniqueCode",
                table: "adi_flushParams");

            migrationBuilder.DropPrimaryKey(
                name: "PK_adi_dic_drug",
                table: "adi_dic_drug");

            migrationBuilder.AlterColumn<string>(
                name: "Drug_UniqueCode",
                table: "adi_dic_drug",
                type: "varchar(255)",
                maxLength: 255,
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "varchar(255)",
                oldMaxLength: 255,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "DRUG_CODE",
                table: "adi_dic_drug",
                type: "varchar(255)",
                maxLength: 255,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(255)",
                oldMaxLength: 255);

            migrationBuilder.AddPrimaryKey(
                name: "PK_adi_dic_drug",
                table: "adi_dic_drug",
                column: "Drug_UniqueCode");

            migrationBuilder.AddForeignKey(
                name: "FK_adi_flushParams_adi_dic_drug_Drug_UniqueCode",
                table: "adi_flushParams",
                column: "Drug_UniqueCode",
                principalTable: "adi_dic_drug",
                principalColumn: "Drug_UniqueCode",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_adi_flushParams_adi_dic_drug_Drug_UniqueCode",
                table: "adi_flushParams");

            migrationBuilder.DropPrimaryKey(
                name: "PK_adi_dic_drug",
                table: "adi_dic_drug");

            migrationBuilder.AlterColumn<string>(
                name: "DRUG_CODE",
                table: "adi_dic_drug",
                type: "varchar(255)",
                maxLength: 255,
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "varchar(255)",
                oldMaxLength: 255,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Drug_UniqueCode",
                table: "adi_dic_drug",
                type: "varchar(255)",
                maxLength: 255,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(255)",
                oldMaxLength: 255);

            migrationBuilder.AddPrimaryKey(
                name: "PK_adi_dic_drug",
                table: "adi_dic_drug",
                column: "DRUG_CODE");

            migrationBuilder.AddForeignKey(
                name: "FK_adi_flushParams_adi_dic_drug_Drug_UniqueCode",
                table: "adi_flushParams",
                column: "Drug_UniqueCode",
                principalTable: "adi_dic_drug",
                principalColumn: "DRUG_CODE",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
